<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function add() {
        this.num += 1;
        return this.num;
      }

      class Math {
        constructor(name, add, num) {
          this.name = name;
          this.add = add;
          this.num = num;
        }
        getName() {
          return this.name;
        }
        addTwo() {
          return this.add.apply(this);
        }
        getNum() {
          return this.num;
        }
      }
      let math = new Math("张山", add, 10);
      console.log(math.getName());
      console.log(math.addTwo());
      console.log(math.getNum());
    </script>
  </body>
</html>
